package com.neuedu.controller;


import com.neuedu.pojo.Result;
import com.neuedu.pojo.THealth;
import com.neuedu.service.ITHealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangsan
 * @since 2024-06-17
 */
@RestController
@RequestMapping("/health")
public class THealthController {
    @Autowired
    ITHealthService healthService;

    // 按用户Id查找健康信息
    /*@GetMapping("/query")
    public Result<List<THealth>> findByElderId(long elderId){
        return healthService.findByeldId( elderId);
    }*/
    @GetMapping("/query/{elderId}")
    public Result findByElderId(@PathVariable("elderId") long elderId){
        return healthService.findByeldId( elderId);
    }
    /**
     * 修改用户健康信息
     */
    @PostMapping("/mohealth")
    public Result modifyHealth(@RequestBody THealth health){
        return healthService.moHealth(health);
    }

    /**
     * 新增用户健康信息
     */
    @PostMapping("/addhealth")
    public  Result addHealth(@RequestBody THealth health){
        return healthService.addHealth(health);
    }
}
